package patrol.mobile.com.mobilepatrol.manager;

import java.util.ArrayList;
import java.util.List;

import io.realm.Realm;
import io.realm.RealmList;
import io.realm.RealmResults;
import io.realm.Sort;
import patrol.mobile.com.mobilepatrol.PatrolApp;
import patrol.mobile.com.mobilepatrol.bean.Qiaoliang;
import patrol.mobile.com.mobilepatrol.bean.QldqjcBjjcb;
import patrol.mobile.com.mobilepatrol.bean.QldqjcBjqsb;
import patrol.mobile.com.mobilepatrol.bean.QldqjcBjqstpb;
import patrol.mobile.com.mobilepatrol.bean.Qldqjcb;
import patrol.mobile.com.mobilepatrol.bean.QljcxjcBjqsb;
import patrol.mobile.com.mobilepatrol.bean.Qljcxjcb;

import static patrol.mobile.com.mobilepatrol.PatrolApp.realm;

/**
 * Created by apple on 17/9/28.
 */

public class QManager {
    /**
     * 获取所有桥梁
     */
    public static List<Qiaoliang> getAllList() {
        return PatrolApp.realm.where(Qiaoliang.class).findAll();
    }
    /**
     * 桥梁是否存在
     *
     * @param code
     * @return
     */
    public static String isExit(String code) {
        List<Qiaoliang> qList = getQList2();
        for (int i = 0; i < qList.size(); i++) {
            String curCode = qList.get(i).qlcode;
            if (code.equals(curCode)) {
                return qList.get(i).qlcode;
            }
        }
        return null;
    }

    /**
     * 获取一个桥梁对象
     *
     * @param qlcode
     * @return
     */
    public static Qiaoliang getQMes(String qlcode) {
        List<Qiaoliang> qList = getQList2();
        for (int i = 0; i < qList.size(); i++) {
            String curCode = qList.get(i).qlcode;
            if (qlcode.equals(curCode)) {
                return qList.get(i);
            }
        }
        return null;
    }
    /**
     * 修改桥梁对象为上传状态
     *
     * @param qlcode
     * @return
     */
    public static void setQLUpState(final String qlcode, final boolean b) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                //先查找后得到对象
                List<Qiaoliang> qls = PatrolApp.realm.where(Qiaoliang.class).equalTo("qlcode",qlcode)
                        .findAll();
                for (int i=0;i<qls.size();i++){
                    qls.get(i).isUp = b;
                }
            }
        });
    }
    /**
     * 获取一个定期检查对象
     *
     * @param qlcode
     * @param qldqjcid
     * @return
     */
    public static Qldqjcb getBridgeDQ(String qlcode, String qldqjcid) {
        RealmList<Qldqjcb> qldqjcbs = getQMes(qlcode).dqjc;
        for (int i = 0; i < qldqjcbs.size(); i++) {
            Qldqjcb item = qldqjcbs.get(i);
            if (qldqjcid.equals(item.qldqjcid)) {
                return item;
            }
        }
        return null;
    }
    /**
     * 获取一个定期检查对象未上传的图片列表
     * @param qldqjcid
     * @return
     */
    public static RealmResults<QldqjcBjqstpb> getBridgeDQNoupTps(String qldqjcid) {
        RealmResults<QldqjcBjqstpb> tps = PatrolApp.realm.where(QldqjcBjqstpb.class).equalTo("qldqjcid",qldqjcid)
                .equalTo("isUp",false).findAll();
        return tps;
    }

    /**
     * 修改图片上传状态
     */
    public static void alterTpUpState(final List<QldqjcBjqstpb> tps, final boolean b) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {

                for (int i=0;i<tps.size();i++){
                    RealmResults<QldqjcBjqstpb> results = realm.where(QldqjcBjqstpb.class).equalTo("id",tps.get(i).id).findAll();

                    results.get(0).isUp = b;
                }
            }
        });
    }

    /**
     * 获取一个桥梁对象未上传的图片列表
     * @param qlcode
     * @return
     */
    public static List<QldqjcBjqstpb> getBridgeNoupTps(String qlcode) {
        List<QldqjcBjqstpb> noUps = new ArrayList<>();
        //所有定期列表
        RealmResults<Qldqjcb> dqs = PatrolApp.realm.where(Qldqjcb.class).equalTo("qlcode",qlcode)
                .findAll();
        for (int i=0;i<dqs.size();i++){
            //一个定期对象的未上传的图片列表
            RealmResults<QldqjcBjqstpb> tps = PatrolApp.realm.where(QldqjcBjqstpb.class).equalTo("qldqjcid",dqs.get(i).qldqjcid)
                    .equalTo("isUp",false)
                    .findAll();
            noUps.addAll(tps);
        }
        return noUps;
    }
    /**
     * 获取一个经常检查对象
     *
     * @param qlcode
     * @param qldqjcid
     * @return
     */
    public static Qljcxjcb getBridgeJC(String qlcode, String qldqjcid) {
        RealmList<Qljcxjcb> bridgeDQ2s = getQMes(qlcode).jcxjc;
        for (int i = 0; i < bridgeDQ2s.size(); i++) {
            Qljcxjcb item = bridgeDQ2s.get(i);
            if (qldqjcid.equals(item.id)) {
                return item;
            }
        }
        return null;
    }

    /**
     * 获取定期检查list
     *
     * @param qlcode
     * @return
     */
    public static List<Qldqjcb> getBridegDQList(String qlcode) {
        List<Qiaoliang> mList = realm.where(Qiaoliang.class).findAll();
        for (int i = 0; i < mList.size(); i++) {
            if (qlcode.equals(mList.get(i).qlcode)) {
                return mList.get(i).dqjc;
            }
        }
        return null;
    }
    /**
     * 获取定期检查没有上传的list
     *
     * @param qlcode
     * @return
     */
    public static List<Qldqjcb> getBridegDQListNoUp(String qlcode) {
        List<Qldqjcb> noups = PatrolApp.realm.where(Qldqjcb.class).equalTo("qlcode",qlcode)
                .equalTo("isUp",false).findAll();
        return  noups;
    }

    /**
     * 修改定期检查list为上传状态
     */
    public static void setBridegDQListUpState(final String qlcode, final boolean b) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                //先查找后得到对象
                List<Qldqjcb> noups = PatrolApp.realm.where(Qldqjcb.class).equalTo("qlcode",qlcode)
                        .equalTo("isUp",!b).findAll();
                for (int i=0;i<noups.size();i++){
                    noups.get(i).isUp = b;
                }
            }
        });
    }
    /**
     * 修改定期检查损坏list为上传状态
     */
    public static void setQldqjcBjqsbListUpState(final String qldqjcid, final boolean b) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                //先查找后得到对象
                List<QldqjcBjqsb> noups = PatrolApp.realm.where(QldqjcBjqsb.class).equalTo("qldqjcid",qldqjcid)
                        .equalTo("isUp",!b).findAll();
                for (int i=0;i<noups.size();i++){
                    noups.get(i).isUp = b;
                }
            }
        });
    }
    /**
     * 修改定期检查图片list为上传状态
     */
    public static void setQldqjcBjqstpbUpState(final String qldqjcid, final boolean b) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                //先查找后得到对象
                List<QldqjcBjqstpb> noups = PatrolApp.realm.where(QldqjcBjqstpb.class).equalTo("qldqjcid",qldqjcid)
                        .equalTo("isUp",!b).findAll();
                for (int i=0;i<noups.size();i++){
                    noups.get(i).isUp = b;
                }
            }
        });
    }

    /**
     * 修改定期检查部件list为上传状态
     */
    public static void setQldqjcBjjcbUpState(final String qldqjcid, final boolean b) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                //先查找后得到对象
                List<QldqjcBjjcb> noups = PatrolApp.realm.where(QldqjcBjjcb.class).equalTo("qldqjcid",qldqjcid)
                        .equalTo("isUp",!b).findAll();
                for (int i=0;i<noups.size();i++){
                    noups.get(i).isUp = b;
                }
            }
        });
    }
    /**
     * 修改定期检查list为上传状态
     */
    public static void setBridegDQUpState(final String qldqjcid, final boolean b) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                //先查找后得到对象
                List<Qldqjcb> noups = PatrolApp.realm.where(Qldqjcb.class).equalTo("qldqjcid",qldqjcid)
                        .equalTo("isUp",!b).findAll();
                for (int i=0;i<noups.size();i++){
                    noups.get(i).isUp = b;
                }
            }
        });
    }
    /**
     * 获取经常检查list
     *
     * @param qlcode
     * @return
     */
    public static List<Qljcxjcb> getBridegJCList(String qlcode) {
//        List<Qiaoliang> mList = realm.where(Qiaoliang.class).findAll();
//        for (int i = 0; i < mList.size(); i++) {
//            if (qlcode.equals(mList.get(i).qlcode)) {
//                return mList.get(i).jcxjc;
//            }
//        }
//        return null;
        List<Qljcxjcb> mList = PatrolApp.realm.where(Qljcxjcb.class).equalTo("qlcode",qlcode)
                .findAll();
        return mList;
    }

    /**
     * 获取经常检查没有上传list
     *
     * @param qlcode
     * @return
     */
    public static List<Qljcxjcb> getBridegJCListNoUp(String qlcode) {
        List<Qljcxjcb> noups = PatrolApp.realm.where(Qljcxjcb.class).equalTo("qlcode",qlcode)
                .equalTo("isUp",false).findAll();
        return noups;
    }

    /**
     * 修改经常检查没有上传list为上传状态
     */
    public static void setBridegJCListUpState(final String qlcode, final boolean b) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                //先查找后得到对象
                List<Qljcxjcb> noups = PatrolApp.realm.where(Qljcxjcb.class).equalTo("qlcode",qlcode)
                        .equalTo("isUp",!b).findAll();
                for (int i=0;i<noups.size();i++){
                    noups.get(i).isUp = b;
                }
            }
        });
    }
    /**
     * 修改经常检查没有上传list为上传状态
     */
    public static void setBridegJCUpState(final String qljcxjcid, final boolean b) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                //先查找后得到对象
                List<Qljcxjcb> noups = PatrolApp.realm.where(Qljcxjcb.class).equalTo("id",qljcxjcid)
                        .equalTo("isUp",!b).findAll();
                for (int i=0;i<noups.size();i++){
                    noups.get(i).isUp = b;
                }
            }
        });
    }
    /**
     * 获取桥梁list
     *
     * @return
     */
    public static RealmResults<Qiaoliang> getQList2() {
        return PatrolApp.realm.where(Qiaoliang.class).findAll();
    }

    /**
     *
     */
    public static void clearQList2() {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                realm.delete(Qiaoliang.class);
                realm.delete(Qldqjcb.class);
                realm.delete(QldqjcBjqsb.class);
                realm.delete(QldqjcBjjcb.class);
                realm.delete(QldqjcBjqstpb.class);
                realm.delete(Qljcxjcb.class);
                realm.delete(QljcxjcBjqsb.class);

            }
        });
    }

    public static void alterBridgeDQ(final Qldqjcb b) {
        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                RealmResults<Qldqjcb> br = realm.where(Qldqjcb.class).equalTo("qldqjcid", b.qldqjcid).findAll();
                Qldqjcb alter = br.get(0);
                alter.roadcode = b.roadcode;
                alter.roadname = b.roadname;
                alter.roadpos = b.roadpos;
                alter.qlcode = b.qlcode;
                alter.qlname = b.qlname;
                alter.xctdm = b.xctdm;
                alter.qc = b.qc;
                alter.zkjg = b.zkjg;
                alter.zdkj = b.zdkj;
                alter.gydw = b.gydw;
                alter.jcny = b.jcny;
                alter.scdzxrq = b.scdzxrq;
                alter.scjcrq = b.scjcrq;
                alter.bcjcrq = b.bcjcrq;
                alter.qh = b.qh;
                alter.ztzkpddj = b.ztzkpddj;
                alter.qlqjzkpf = b.qlqjzkpf;
                alter.byxxzkpf = b.byxxzkpf;
                alter.jcxyhjy = b.jcxyhjy;

                alter.jlr = b.jlr;
                alter.fzr = b.fzr;

                alter.xcjcsj = b.xcjcsj;
                alter.qssm = b.qssm;

                alter.weather_id = b.weather_id;
                alter.fen_total_id = b.fen_total_id;
                alter.fen_ser_id = b.fen_ser_id;
                alter.fen_clean_id = b.fen_clean_id;
            }
        });
    }

    public static void alterBridgeJC(final Qljcxjcb b) {
        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                RealmResults<Qljcxjcb> br = realm.where(Qljcxjcb.class).equalTo("id", b.id).findAll();
                Qljcxjcb alter = br.get(0);
                alter.id = b.id;
                alter.roadcode = b.roadcode;
                alter.roadname = b.roadname;
                alter.roadpos = b.roadpos;
                alter.qlcode = b.qlcode;
                alter.qlname = b.qlname;
                alter.gydw = b.gydw;

                alter.jlr = b.jlr;
                alter.fzr = b.fzr;
                alter.jcrq = b.jcrq;
            }
        });
    }

    /**
     * 删除一个桥梁定期检查对象
     * bj
     * qs
     * tp
     * @param qldqjcid
     */
    public static void delBridgeDQ(final String qldqjcid) {
        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                RealmResults<Qldqjcb> br = realm.where(Qldqjcb.class).equalTo("qldqjcid", qldqjcid).findAll();
                RealmResults<QldqjcBjjcb> bjs = realm.where(QldqjcBjjcb.class).equalTo("qldqjcid", qldqjcid).findAll();
                RealmResults<QldqjcBjqsb> qss = realm.where(QldqjcBjqsb.class).equalTo("qldqjcid", qldqjcid).findAll();
                RealmResults<QldqjcBjqstpb> tps = realm.where(QldqjcBjqstpb.class).equalTo("qldqjcid", qldqjcid).findAll();
                bjs.deleteAllFromRealm();
                qss.deleteAllFromRealm();
                tps.deleteAllFromRealm();
                br.deleteAllFromRealm();
            }
        });
    }

    public static void delBridgeJC(final String qljcxjcid) {
        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                RealmResults<Qljcxjcb> br = realm.where(Qljcxjcb.class).equalTo("id", qljcxjcid).findAll();
                RealmResults<QldqjcBjqsb> qss = realm.where(QldqjcBjqsb.class).equalTo("id", qljcxjcid).findAll();
                qss.deleteAllFromRealm();
                br.deleteAllFromRealm();
            }
        });
    }

    /**
     * 删除定期检查缺损列表一个对象
     *
     * @param id
     */
    public static void delBridgebjqs(final String id) {
        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                RealmResults<QldqjcBjqsb> br = realm.where(QldqjcBjqsb.class).equalTo("id", id).findAll();
                QldqjcBjqsb alter = br.get(0);
                alter.deleteFromRealm();
            }
        });
    }

    /**
     * 删除定期部件检查列表一个对象
     *
     * @param id
     */
    public static void delBridgebjjc(final String id) {
        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                RealmResults<QldqjcBjjcb> br = realm.where(QldqjcBjjcb.class).equalTo("id", id).findAll();
                QldqjcBjjcb alter = br.get(0);
                alter.deleteFromRealm();
            }
        });
    }

    /**
     * @param id
     */
    public static QldqjcBjqsb getBridgebjqs(final String id) {
        final QldqjcBjqsb[] obj = new QldqjcBjqsb[1];
        realm.executeTransaction(new Realm.Transaction() {


            @Override
            public void execute(Realm realm) {
                RealmResults<QldqjcBjqsb> br = realm.where(QldqjcBjqsb.class).equalTo("id", id).findAll();
                obj[0] = br.get(0);

            }

        });
        return obj[0];

    }

    /**
     * @param id
     */
    public static QldqjcBjjcb getBridgebjjc(final String id) {
        final QldqjcBjjcb[] obj = new QldqjcBjjcb[1];
        realm.executeTransaction(new Realm.Transaction() {


            @Override
            public void execute(Realm realm) {
                RealmResults<QldqjcBjjcb> br = realm.where(QldqjcBjjcb.class).equalTo("id", id).findAll();
                obj[0] = br.get(0);

            }

        });
        return obj[0];

    }

    /**
     * 获取一个定期检查对象的缺损列表
     */
    public static List<QldqjcBjqsb> getBridgeDQbjqsList(final String qldqjcid) {
        List<QldqjcBjqsb> list = PatrolApp.realm.where(QldqjcBjqsb.class).equalTo("qldqjcid",qldqjcid).findAll();
        return setQldqjcBjqsbIndex(list);
    }

    /**
     * 获取一个定期检查对象部件检查列表
     */
    public static List<QldqjcBjjcb> getQldqjcBjjcbList(final String qldqjcid) {
        RealmResults<QldqjcBjjcb> list = PatrolApp.realm.where(QldqjcBjjcb.class).equalTo("qldqjcid",qldqjcid).findAll();
        return setQldqjcBjjcbIndex(list.sort("wxsj", Sort.DESCENDING));
    }


    /**
     * 获取一个经常检查对象的缺损列表
     */
    public static List<QljcxjcBjqsb> getBridgeJCbjqsList(final String qljcxjcid) {
        List<QljcxjcBjqsb> list = PatrolApp.realm.where(QljcxjcBjqsb.class).equalTo("qljcxjcid",qljcxjcid).findAll();
        return setQljcxjcBjqsbIndex(list);
    }

    /**
     * 删除经常检查缺损列表一个对象
     *
     * @param id
     */
    public static void delBridgeJCbjqs(final String id) {
        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                RealmResults<QljcxjcBjqsb> br = realm.where(QljcxjcBjqsb.class).equalTo("id", id).findAll();
                QljcxjcBjqsb alter = br.get(0);
                alter.deleteFromRealm();
            }
        });
    }

    /**
     * @param id
     */
    public static QljcxjcBjqsb getBridgeJCbjqs(final String id) {
        final QljcxjcBjqsb[] obj = new QljcxjcBjqsb[1];
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {


            @Override
            public void execute(Realm realm) {
                RealmResults<QljcxjcBjqsb> br = realm.where(QljcxjcBjqsb.class).equalTo("id", id).findAll();
                obj[0] = br.get(0);

            }

        });
        return obj[0];

    }

    public static void insertQL(Qiaoliang ql) {
        PatrolApp.realm.beginTransaction();
        PatrolApp.realm.insert(ql);
        PatrolApp.realm.commitTransaction();


    }
    public static void delQL(final Qiaoliang qiao) {
        realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                RealmResults<Qiaoliang> qls = realm.where(Qiaoliang.class).equalTo("qlcode",qiao.qlcode).findAll();
                RealmResults<Qldqjcb> dqs = realm.where(Qldqjcb.class).equalTo("qlcode",qiao.qlcode).findAll();

                RealmResults<Qljcxjcb> jcs = realm.where(Qljcxjcb.class).equalTo("qlcode",qiao.qlcode).findAll();
//

                if (dqs.size()>0){
                    for (int i=0;i<dqs.size();i++){
                        RealmResults<QldqjcBjjcb> bjs = realm.where(QldqjcBjjcb.class).equalTo("qldqjcid",dqs.get(i).qldqjcid).findAll();
                        RealmResults<QldqjcBjqsb> qss = realm.where(QldqjcBjqsb.class).equalTo("qldqjcid",dqs.get(i).qldqjcid).findAll();
                        RealmResults<QldqjcBjqstpb> tps = realm.where(QldqjcBjqstpb.class).equalTo("qldqjcid",dqs.get(i).qldqjcid).findAll();
                        bjs.deleteAllFromRealm();
                        qss.deleteAllFromRealm();
                        tps.deleteAllFromRealm();
                    }
                }


                if (jcs.size()>0){
                    for (int i=0;i<jcs.size();i++){
                        RealmResults<QljcxjcBjqsb> jxqss = realm.where(QljcxjcBjqsb.class).equalTo("qljcxjcid",jcs.get(i).id).findAll();
                        jxqss.deleteAllFromRealm();
                    }
                }

                dqs.deleteAllFromRealm();
                jcs.deleteAllFromRealm();
                qls.deleteAllFromRealm();


            }
        });


    }
    /**
     * 桥梁定期检查列表，逆序
     */
    public static List<Qldqjcb> getQLDQList(String qlcode) {
        RealmResults<Qldqjcb> results = PatrolApp.realm.where(Qldqjcb.class).equalTo("qlcode",qlcode).findAll();
        return setDQIndex(results.sort("bcjcrq", Sort.DESCENDING));

    }
    /**
     * 桥梁经常性检查列表，逆序
     */
    public static List<Qljcxjcb> getQLJCList(String qlcode) {
        RealmResults<Qljcxjcb> results = PatrolApp.realm.where(Qljcxjcb.class).equalTo("qlcode",qlcode).findAll();
        return setQljcxjcbIndex(results.sort("jcrq", Sort.DESCENDING));

    }
    /**
     * 改变勾选状态
     */
    public static void setcbState(final List<Qiaoliang> mList, final boolean b) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                for (int i=0;i<mList.size();i++){
                    mList.get(i).isCheck = b;
                }
            }
        });
    }
    /**
     * 添加序号
     */
    public static List<Qldqjcb> setDQIndex(final List<Qldqjcb> list) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                for (int i=0;i<list.size();i++){
                    list.get(i).index = i+1;
                }

            }
        });
        return list;
    }
    public static List<QldqjcBjjcb> setQldqjcBjjcbIndex(final List<QldqjcBjjcb> list) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                for (int i=0;i<list.size();i++){
                    list.get(i).index = i+1;
                }

            }
        });
        return list;
    }
    public static List<QldqjcBjqsb> setQldqjcBjqsbIndex(final List<QldqjcBjqsb> list) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                for (int i=0;i<list.size();i++){
                    list.get(i).index = i+1;
                }

            }
        });
        return list;
    }
    public static List<Qljcxjcb> setQljcxjcbIndex(final List<Qljcxjcb> list) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                for (int i=0;i<list.size();i++){
                    list.get(i).index = i+1;
                }

            }
        });
        return list;
    }
    public static List<QljcxjcBjqsb> setQljcxjcBjqsbIndex(final List<QljcxjcBjqsb> list) {
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                for (int i=0;i<list.size();i++){
                    list.get(i).index = i+1;
                }

            }
        });
        return list;
    }

}
